<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表渲染：v-for</title>
    <script src="/js/vue.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for='item in stars'>
                {{item}}
            </li>
        </ul>
        <h3>学生列表(带索引值)</h3>
        <ul>
            <!-- key为索引值 -->
            <li v-for='item,key in students'>
                <h4>索引值：{{key}}——————姓名：{{item.studentName}}</h4>
                <p>年龄：{{item.age}}——————学校：{{item.school}}</p>
            </li>
        </ul>

        <h3>循环对象里的内容</h3>
        <ul>
            <li v-for='item,key in students[0]'>
                key:{{key}}----
                value:{{item}}
            </li>
        </ul>

        <h3>条件+循环渲染（将偶数年龄的学生渲染出来）</h3>
        <ol>
            <!-- 先循环，再判断 -->
            <li v-for='item,key in students' v-if='item.age%2==0' :key='key'>
                <h4>索引值：{{key}}——————姓名：{{item.studentName}}</h4>
                <p>年龄：{{item.age}}——————学校：{{item.school}}</p>
            </li>
        </ol>
    </div>
    <script>
        let app = new Vue({
            el: '#app',
            data:{
                stars:['Abc','Bcd','Cde','Def'],
                students:[
                    {
                        studentName:'AAA',
                        age:16,
                        school:'BBB'
                    },
                    {
                        studentName:'BBB',
                        age:17,
                        school:'CCC'
                    },
                    {
                        studentName:'DDD',
                        age:18,
                        school:'EEE'
                    },
                    {
                        studentName:'DDD',
                        age:15,
                        school:'EEE'
                    }
                ],
            }
        })
    </script>
</body>
</html>